#ifndef MAPSCEN_H
#define MAPSCEN_H

#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include "edgeitem.h"
#include "nodeitem.h"
#include <QDebug>

class MapScen : public QGraphicsScene
{
    Q_OBJECT
public:
    explicit MapScen(QObject *parent = 0);
    enum MouseEventType{rbMousePress,lbMousePress,rbMouseRelease,lbMouseRelease, mMove};
    enum ScenStatus{addNode,addEdge,editNode,editEdge,viewScen};
 Q_ENUMS(MouseEventType)


private:
    QPainterPath ppath;
    QPointF startLinePoint;
    EdgeItem  *new_edge;
    void drowPoint(MouseEventType eventType, QPointF p);
    void drowLine(MouseEventType eventType, QPointF p);
    ScenStatus scenStatus;
    bool createEdge;

public slots:
    void loadMap();
    void addLayer();
    void drawPaintCmd(MouseEventType eventType, QPointF p);
    void setScenStatus(int scStatus);

signals:
    void mScenEvent(MouseEventType eventType, QPointF p);

protected:
    //void keyPressEvent(QKeyEvent *event);
   // void drawBackground(QPainter *painter, const QRectF &rect);
    //void drawForeground(QPainter *painter, const QRectF &rect);
    void mousePressEvent(QGraphicsSceneMouseEvent  *event );
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
};

#endif // MAPSCEN_H
